package name.jiaosha.air.user.domain;
import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import name.jiaosha.air.company.domain.Company;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * The persistent class for the login_user database table.
 * 
 * @author BEA Workshop
 */
@Entity()
@Table(name="login_user")
public class LoginUser  implements Serializable {
	//default serial version id, required for serializable classes.
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String qq;
	private Boolean enabled;
	private String name;
	private String password;
	private java.util.Set<LoginLog> loginLogs;
	private Company company;

    public LoginUser() {
    }

    @Id()
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="id", unique=true, nullable=false, precision=11)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
    
	@Basic()
	@Column(name="qq", unique=true, nullable=false, length=20)
	public String getQq() {
		return this.qq;
	}
	public void setQq(String qq) {
		this.qq = qq;
	}

	@Basic()
	@Column(name="enabled", length=1)
	public Boolean getEnabled() {
		return this.enabled;
	}
	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	@Basic()
	@Column(name="name", length=10)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}

	@Basic()
	@Column(name="password", length=32)
	public String getPassword() {
		return this.password;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	//bi-directional many-to-one association to LoginLog
	@OneToMany(mappedBy="loginUser", fetch=FetchType.LAZY)
	public java.util.Set<LoginLog> getLoginLogs() {
		return this.loginLogs;
	}
	public void setLoginLogs(java.util.Set<LoginLog> loginLogs) {
		this.loginLogs = loginLogs;
	}

	//bi-directional many-to-one association to Company
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="com_id", referencedColumnName="id")
	public Company getCompany() {
		return this.company;
	}
	public void setCompany(Company company) {
		this.company = company;
	}

	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (!(other instanceof LoginUser)) {
			return false;
		}
		LoginUser castOther = (LoginUser)other;
		return new EqualsBuilder()
			.append(this.getQq(), castOther.getQq())
			.isEquals();
    }
    
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getQq())
			.toHashCode();
    }   

	public String toString() {
		return new ToStringBuilder(this)
			.append("qq", getQq())
			.toString();
	}
}